package com.orifine.orm.information;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import com.orifine.orm.Information;
import com.orifine.orm.model.ColumnModel;

public class NumberRandomInfo implements Information {
	private int begin = 0;
	private int count = 1000;
	
	private Map<Integer, Integer> valueMap = new HashMap<Integer, Integer>();

	public NumberRandomInfo(Integer count){
		if(count != null) this.count = count;
	}
	
	public NumberRandomInfo(Integer count, Integer begin){
		if(count != null) this.count = count;
		if(begin != null) this.begin = begin;
	}
	
	@Override
	public Object value(int index, ColumnModel columnMapper) {
		Integer value = valueMap.get(index);
		if(value != null){
			return value;
		} else {
			value = random.nextInt(count) + begin;
			valueMap.put(index, value);
			return value;
		}
	}

	@Override
	public void init(ColumnModel columnMapper) {
	}

	private static Random random = new Random();
}
